#include "lan2caltime.h"
#include <QDebug>
#include <QLabel>
LAN2STA
Lan2CalTime::Lan2CalTime(QWidget *parent, int width, int height) : QWidget(parent)
{
    this->setAttribute(Qt::WA_StyledBackground,true);
    this->setStyleSheet("QWidget{background:#fdfdfd}");

    this->setFixedHeight(height);
    this->setFixedWidth(width);

    hbox=new QHBoxLayout();
    this->setLayout(hbox);

    le_hh=new Lan2CalLineEdit(mwle,mwle,this);
    le_mm=new Lan2CalLineEdit(mwle,mwle,this);
    le_ss=new Lan2CalLineEdit(mwle,mwle,this);
    le_hh->setObjectName("le_hh");
    le_mm->setObjectName("le_mm");
    le_ss->setObjectName("le_ss");
    connect(le_hh,SIGNAL(sign_hhclick()),this,SLOT(slot_hhclick()));
    connect(le_mm,SIGNAL(sign_mmclick()),this,SLOT(slot_mmclick()));
    connect(le_ss,SIGNAL(sign_ssclick()),this,SLOT(slot_ssclick()));


    mplane_hh=new Lan2CalHhp(240,80);//弹出小时面板选择
    connect(mplane_hh,SIGNAL(sign_sendword(QString)),this,SLOT(slot_hhsendword(QString)));
//    mplane_hh->show();
    mplane_hh->hide();
    mplane_hh->setHidden(true);

    mplane_mm=new Lan2CalMmp(240,200);
    connect(mplane_mm,SIGNAL(sign_sendword(QString)),this,SLOT(slot_mmsendword(QString)));
//    mplane_mm->show();
    mplane_mm->hide();
    mplane_mm->setHidden(true);

    mplane_ss=new Lan2CalSsp(240,200);
    connect(mplane_ss,SIGNAL(sign_sendword(QString)),this,SLOT(slot_sssendword(QString)));
//    mplane_ss->show();
    mplane_ss->hide();
    mplane_ss->setHidden(true);




    QLabel* lal_time=new QLabel(this);
    QLabel*lal_maohao=new QLabel(this);
    QLabel*lal_maohao2=new QLabel(this);

    QFont ftime;
//    ftime.setBold(true);
    ftime.setPointSize(8);
    lal_time->setFont(ftime);
    lal_time->setText("时间");
    lal_maohao-> setText(":");
    lal_maohao2-> setText(":");

    QFont f;
//     f.setBold(true);
    f.setPointSize(12);
    lal_maohao->setFont(f);
    lal_maohao2->setFont(f);



    hbox->addWidget(lal_time);
    hbox->addWidget(le_hh);
    hbox->addWidget(lal_maohao);
    hbox->addWidget(le_mm);
    hbox->addWidget(lal_maohao2);
    hbox->addWidget(le_ss);
    hbox->addStretch();
}

void Lan2CalTime::method_sethhtxt(const QString &txt)
{
    le_hh->method_setText(txt);
}

void Lan2CalTime::method_setmmtxt(const QString &txt)
{
    le_mm->method_setText(txt);
}

void Lan2CalTime::method_setsstxt(const QString &txt)
{
    le_ss->method_setText(txt);
}

void Lan2CalTime::method_sethhmmsstxt(const QString &hh, const QString &mm, const QString &ss)
{
    le_hh->setText(hh);
    le_mm->setText(mm);
    le_ss->setText(ss);
}

QString Lan2CalTime::method_gethh() const
{
    return le_hh->text();
}

QString Lan2CalTime::method_getmm() const
{
    return le_mm->text();
}

QString Lan2CalTime::method_getss() const
{
    return le_ss->text();
}

void Lan2CalTime::method_movehhplane(int x, int y)
{
    mplane_hh->move(x,y);

}

void Lan2CalTime::method_setplanehhVisble(bool b)
{
    mplane_hh->setHidden(b);
}

void Lan2CalTime::method_movemmplane(int x, int y)
{
    mplane_mm->move(x,y);
}

void Lan2CalTime::method_movessplane(int x, int y)
{
    mplane_ss->move(x,y);
}

void Lan2CalTime::method_delhhplane()
{
    mplane_hh->deleteLater();
}

void Lan2CalTime::method_delmmplane()
{
    mplane_mm->deleteLater();
}

void Lan2CalTime::method_delssplane()
{
    mplane_ss->deleteLater();
}

void Lan2CalTime::method_hideAllPlane()
{
    mplane_hh->hide();
    mplane_mm->hide();
    mplane_ss->hide();
}

void Lan2CalTime::slot_hhclick()
{
    mplane_hh->setHidden(true);

    if(mplane_hh->isHidden()){

        mplane_hh->setHidden(false);
    }


//    mplane_hh->setHidden(false);
    mplane_hh->show();
}

void Lan2CalTime::slot_mmclick()
{
    mplane_mm->setHidden(true);

    if(mplane_mm->isHidden()){

        mplane_mm->setHidden(false);
    }

    mplane_mm->show();
}

void Lan2CalTime::slot_ssclick()
{
    mplane_ss->setHidden(true);

    if(mplane_ss->isHidden()){

        mplane_ss->setHidden(false);
    }
    mplane_ss->show();
}

void Lan2CalTime::slot_hhsendword(const QString & s)
{
    le_hh->setText(s);
}

void Lan2CalTime::slot_mmsendword(const QString & s)
{
    le_mm->setText(s);
}

void Lan2CalTime::slot_sssendword(const QString & s)
{
    le_ss->setText(s);
}

void Lan2CalTime::slot_reset2start()
{
    le_hh->setText("00");
    le_mm->setText("00");
    le_ss->setText("00");
}

void Lan2CalTime::slot_reset2end()
{
    le_hh->setText("23");
    le_mm->setText("59");
    le_ss->setText("59");
}

//void Lan2CalTime::slot_reset2all()
//{

//}


LAN2END
